// 加载公共样式
require('../../assets/css/common.less')
// 自己的样式
require('./course-detail.less')
//axios工具类
const request = require('../../utils/request')
//服务器地址
const API = 'http://fitness.h5.itsource.cn:3701'
window.onload = () => {

    // 获取元素怒
    let coursebtn=document.querySelector('#coursebtn')
    const player=document.querySelector('#player')
    const crdetit=document.querySelector('.crdetit')
    // console.log(location.search);
    const courseId = location.search.split('=')[1]
    console.log(courseId);
    //  获取数据
    function getData() {
        request.get('/api/train/courseDetail', {
            params: {
                id: courseId
            }
        }).then(res => {
            // console.log(res.data);
            let {errno,data}=res.data
            if(errno===0){
                console.log(22222222222);
                console.log(data.fragments);
                
                player.src=API+data.fragments[courseId-2].videoUrl
                crdetit.textContent=data.fragments[courseId-2].title
              localStorage.setItem('fragments',JSON.stringify(data.fragments))
            }
        })
    }
    getData()
    // coursebtn.addEventListener('')
    let fragment=JSON.parse(localStorage.getItem('fragments'))
    // console.log(fragment);

}